<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <title>帖子详情</title>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.4.1/jquery.min.js"></script>
    <link rel="stylesheet" href="ForumShare.css">
    <style>
    </style>
</head>
<body>
<div class="forum-container">
    <header class="wenda-header">
        <ul>
            <li><img src="images/head.png"> </li>
            <li><a href="http://a.app.qq.com/o/simple.jsp?pkgname=com.yuekao.kaoyanquestion">下载</a></li>
        </ul>
    </header>

    <div class="postDetail">
        <div id="postTitle">
            考研之路艰辛孤独,愿大家一起并肩战斗
        </div>
        <div class="postUserInfo">
            <ul>
                <li><img id="headImage"/></li>
                <li id="name">陈哈哈</li>
                <li>楼主</li>
                <li id="time">刚刚</li>
            </ul>
        </div>
        <img id="contentImage">
        <div class="content" id="content">全球最大的中文搜索引擎、致力于让网民更便捷地获取信息，找到所求。百度超过千亿的中文网页数据库，可以瞬间找到相关的搜索结果。</div>

        <div class="lineSpace"></div>
        <div class="allAnswers">
            <div></div>
            <div>
                <p id="allAnswersNumber">全部跟帖</p>
            </div>
        </div>
        <div class="postList" id="post-list">
            <div class="item">
                <ul>
                    <li><img src="images/XL.png" alt="图片"/></li>
                    <li>张冬青</li>
                    <li class="isAdmin">楼主</li>
                    <li>全球最大的中文搜索引擎、致力于让网民更便捷地获取信息，找到所求。百度超过千亿的中文网页数据库，可以瞬间找到相关的搜索结果。</li>
                </ul>
                <div class="item_bottom">
                    <span>刚刚</span>
                    <span  class="comment"><img src="images/reply_icon.png" alt="图片"/>回复</span>
                    <span><img src="images/un_agree.png" alt="图片"/>12</span></div>
            </div>
        </div>
    </div>

    <div class="btn">
        <div><img src="images/post_agree.png" alt="图片" /><span id="agree">20赞</span></div>
        <div class="line"></div>
        <div><img src="images/reply_post.png" alt="图片"/>我要回帖</div>
    </div>
</div>
<script src="https://cdn.bootcss.com/js-url/2.5.2/url.min.js"></script>
<script type="text/javascript">
    $(function() {
        $('#openApp').onclick = function () {
            window.location.href = "okaoyan.com://";
            window.setTimeout(function(){
                window.location.href = "http://a.app.qq.com/o/simple.jsp?pkgname=com.yuekao.kaoyanquestion";//打开app下载地址，有app同事提供
            },2000)
        };
        //获取参数
        var id = url('?id');
        //获得题目详情
        $.ajax({
            url: 'https://api.okaoyan.com:9293/api/v3/post/detail_ios?post_id='+id,
            type: 'GET',
            dataType: 'json',

            success: function(data) {
                console.log(data);
                var forum = data.post;

                $('#postTitle').text(forum.title);
                $('#name').text(forum.user.username);
                $('#headImage').attr('src', 'https://api.okaoyan.com:9293'+forum.user.avatar);
                $('#content').text(forum.content);
                $('#agree').text(forum.agrees+' 赞')
                if (forum.images.length != 0) {
                    $('#contentImage').attr('src', 'https://api.okaoyan.com:9293'+forum.images[0]);
                }
            },
        })

        $.ajax({
            url: 'https://api.okaoyan.com:9293/api/v3/post/replies_ios?post_id='+id,
            type: 'GET',
            dataType: 'json',

            success: function(data) {
                console.log(data);
                var reply = data.replies;

                var replyHtml = "";
                for (var i = 0, len = reply.length; i < len; i++) {
                    var replyArr = reply[i];
                    replyHtml += "<div class='item'>"+
                            "<ul><li><img src="+'https://api.okaoyan.com:9293'+replyArr.user.avatar+" alt='图片'/></li>"+
                            "<li>"+replyArr.user.username+"</li>"+
                            "<li class='isAdmin'>楼主</li>"+
                            "<li>"+replyArr.content+"</li>"+
                            "</ul><div class='item_bottom'>"+
                            "<span>"+replyArr.created_at+"</span>"+
                            "<span  class='comment'><a href='replyPost.html' title='回复'><img src='images/reply_icon.png' alt='图片'/>回复</a></span>"+
                            "<span> <a href='#' title='回复'><img src='images/un_agree.png' alt='图片'/>12</a></span></div>"+
                            "</div>";
                }
                $('#post-list').empty();
                $('#post-list').append(replyHtml);

            },
        })


    })

</script>
</body>


</html>
